from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Chrome(executable_path='chromedriver.exe')
# # 2.输入访问地址（URL）
driver.get("http://121.43.169.97:8848/pageA.html")

#option
sleep(2)
#选择'上海'
# 通过css定位，通过标签option的属性值 value 定位
driver.find_element_by_css_selector("[value='sh']").click()
sleep(2)
driver.find_element_by_css_selector("[value='gz']").click()

#select
el = driver.find_element_by_css_selector("#selectA")
select = Select(el)
sleep(2)
# 1).选择‘广州’
select.select_by_visible_text("广州")
# 2).暂停2秒，选择‘上海’
sleep(2)
select.select_by_visible_text("上海")
# 3).暂停2秒，选择‘北京’
sleep(2)
select.select_by_visible_text("北京")
